package com.lightsaber.trade.cloth.dao.planning;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.hibernate.Query;
import org.springframework.stereotype.Component;

import com.lightsaber.trade.core.dao.BaseDao;
import com.lightsaber.trade.cloth.entity.planning.Level2BreakDown;

@Component
public class Level2BreakDownDao extends BaseDao<Level2BreakDown, String> {

    public List<Level2BreakDown> findByProgrammePlanningItemId(final String ppiId) {
        eq("programmePlanningItem.id", ppiId);
        return list();
    }

    public void deleteByProgrammePlanningItemId(final String ppiId) {

        String hql = "delete from Level2BreakDown bd where bd.programmePlanningItem.id=:ppiId";
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("ppiId", ppiId);
        Query q = this.createQuery(hql, map);
        q.executeUpdate();
    }

}
